package com.estronger.shopmanage.ui.aftermarket.views;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.estronger.shopmanage.R;
import com.estronger.shopmanage.ui.aftermarket.adapter.GoodsAdapater;
import com.estronger.shopmanage.ui.aftermarket.bean.AftermarketItem;

import java.util.List;

public class GoodsView extends LinearLayout {

    List<AftermarketItem.OrderItem> dataArray;
    Context mContext;

    @BindView(R.id.recycle_view)
    RecyclerView recyclerView;

    GoodsAdapater goodsAdapater;

    public GoodsView(Context context) {
        super(context);
    }
    public GoodsView(Context context, AttributeSet attr){
        super(context,attr);
        this.mContext = context;
        View view = View.inflate(context, R.layout.item_app_goods_layout, this);
        ButterKnife.bind(this,view);
        goodsAdapater = new GoodsAdapater(mContext);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerView.setAdapter(goodsAdapater);
    }

    public void setDataArray(List<AftermarketItem.OrderItem> dataArray) {
        this.dataArray = dataArray;
        goodsAdapater.setDatas(dataArray);
        goodsAdapater.notifyDataSetChanged();
    }

}
